package com.ifonly.interceptor;

import java.util.ArrayList;
import java.util.List;

/**
 * @author <a href="mailto:ifonlymaster@163.com">ifonly</a>
 * @version 1.0 2015-12-10 13:26
 * @since JDK 1.6
 */
public class GlobalInterceptors {

    private List<Interceptor> globalInterceptors = new ArrayList<Interceptor>();

    private GlobalInterceptors() {

    }

    private static class InstanceHolder {
        private static GlobalInterceptors instance = new GlobalInterceptors();
    }

    public static GlobalInterceptors getInstance() {
        return InstanceHolder.instance;
    }

    public void add(Interceptor interceptor) {
        globalInterceptors.add(interceptor);
    }

    public Interceptor[] globalInterceptors() {
        return globalInterceptors.toArray(new Interceptor[globalInterceptors.size()]);
    }

}
